package com.monk.manejobd_android;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.util.Log;

public class DbHelper extends SQLiteOpenHelper {

	static final String TAG = "DbHelper";
	static final String DB_NAME = "prueba.db"; //
	static final int DB_VERSION = 1; //
	static final String TABLE = "tabla"; //
	static final String C_ID = BaseColumns._ID;
	static final String C_PACKAGE_NAME = "created_at";
	static final String C_NAME = "source";
	static final String[] DB_TEXT_COLUMNS = { C_NAME };

	Context context;

	public DbHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
		this.context = context;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql = "create table " + TABLE + " (" + C_ID
				+ " int primary key, " + C_PACKAGE_NAME + " text, "
				+ C_NAME + " text)"; //
		db.execSQL(sql); //
		Log.d(TAG, "onCreated sql: " + sql);
	}

	// Called whenever newVersion != oldVersion
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { //
		// Typically do ALTER TABLE statements, but...we're just in
		// development,
		// so:
		db.execSQL("drop table if exists " + TABLE); // drops the old
														// database
		Log.d(TAG, "onUpdated");
		onCreate(db); // run onCreate to get new database

	}

}
